package Dome;

import java.util.ArrayList;

public class Student3Test {
    public static void main(String[] args) {
        ArrayList<Student3> students = new ArrayList<>();
        students.add(new Student3(1, "张三"));
        students.add(new Student3(2, "李四"));
        students.add(new Student3(3, "王五"));

        System.out.println("初始学生列表: " + students);
        for (int i = 0; i < students.size(); i++) {
            Student3 s = students.get(i);

            if (s.getName().equals("张三")){
                s.setName("张三丰");
            }
            if(s.getName().equals("王五")){
                students.remove(s);
            }
        }
        for (int i = 0; i < students.size(); i++) {
            System.out.println(
                    students.get(i)
            );
        }
    }
}
